﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataMaterialBindRecord" @search="()=>{getTableDataMaterialBindRecord();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="LineCode_FormItem" prop="LineCode" :label="$t('message.autotrans._Model_MaterialBindRecord_lineCode')">
            <el-input v-model="searchDataMaterialBindRecord.LineCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="StationCode_FormItem" prop="StationCode" :label="$t('message.autotrans._Model_MaterialBindRecord_stationCode')">
            <el-input v-model="searchDataMaterialBindRecord.StationCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OrderCode_FormItem" prop="OrderCode" :label="$t('message.autotrans._Model_MaterialBindRecord_orderCode')">
            <el-input v-model="searchDataMaterialBindRecord.OrderCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ScheduleCode_FormItem" prop="ScheduleCode" :label="$t('message.autotrans._Model_MaterialBindRecord_scheduleCode')">
            <el-input v-model="searchDataMaterialBindRecord.ScheduleCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="SnNumber_FormItem" prop="SnNumber" :label="$t('message.autotrans._Model_MaterialBindRecord_snNumber')">
            <el-input v-model="searchDataMaterialBindRecord.SnNumber" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="AssemblyMaterialCode_FormItem" prop="AssemblyMaterialCode" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialCode')">
            <el-input v-model="searchDataMaterialBindRecord.AssemblyMaterialCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="AssemblyMaterialQty_FormItem" prop="AssemblyMaterialQty" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialQty')">
            <el-input v-model="searchDataMaterialBindRecord.AssemblyMaterialQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="AssemblySort_FormItem" prop="AssemblySort" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblySort')">
            <el-input v-model="searchDataMaterialBindRecord.AssemblySort" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="AssemblyTime_FormItem" prop="AssemblyTime" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyTime')">
            <el-input v-model="searchDataMaterialBindRecord.AssemblyTime" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="AssemblyMaterialName_FormItem" prop="AssemblyMaterialName" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialName')">
            <el-input v-model="searchDataMaterialBindRecord.AssemblyMaterialName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="AssemblyMaterialVersion_FormItem" prop="AssemblyMaterialVersion" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialVersion')">
            <el-input v-model="searchDataMaterialBindRecord.AssemblyMaterialVersion" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="AssemblyMaterialSn_FormItem" prop="AssemblyMaterialSn" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialSn')">
            <el-input v-model="searchDataMaterialBindRecord.AssemblyMaterialSn" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="MaterialBatchNo_FormItem" prop="MaterialBatchNo" :label="$t('message.autotrans._Model_MaterialBindRecord_materialBatchNo')">
            <el-input v-model="searchDataMaterialBindRecord.MaterialBatchNo" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Uploadflag_FormItem" prop="Uploadflag" :label="$t('message.autotrans._Model_MaterialBindRecord_uploadflag')">
            <el-select v-model="searchDataMaterialBindRecord.Uploadflag" clearable>
               <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
               <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_MaterialBindRecord_CreateTime')">
            <el-date-picker v-model="searchDataMaterialBindRecord.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_MaterialBindRecord_UpdateTime')">
            <el-date-picker v-model="searchDataMaterialBindRecord.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_MaterialBindRecord_CreateBy')">
            <el-input v-model="searchDataMaterialBindRecord.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_MaterialBindRecord_UpdateBy')">
            <el-input v-model="searchDataMaterialBindRecord.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/Record/MaterialBindRecord/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/Record/MaterialBindRecord/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/Record/MaterialBindRecord/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/Record/MaterialBindRecord/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/Record/MaterialBindRecord/MaterialBindRecordExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefMaterialBindRecord" v-bind="tableDataMaterialBindRecord">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/Record/MaterialBindRecord/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/Record/MaterialBindRecord/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/Record/MaterialBindRecord/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageRecordMaterialBindRecordIndex;true;TyMES.Record.Controllers;MaterialBindRecord">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { materialbindrecordApi } from '/@/api/record/materialbindrecord';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const router = useRouter();

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateMaterialBindRecord = reactive({
    
});

const searchDataMaterialBindRecord = ref({
        LineCode: '',
        StationCode: '',
        OrderCode: '',
        ScheduleCode: '',
        SnNumber: '',
        AssemblyMaterialCode: '',
        AssemblyMaterialQty: '',
        AssemblySort: '',
        AssemblyTime: '',
        AssemblyMaterialName: '',
        AssemblyMaterialVersion: '',
        AssemblyMaterialSn: '',
        MaterialBatchNo: '',
        Uploadflag: undefined,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefMaterialBindRecord = ref();
const tableDataMaterialBindRecord = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page产线编码'),key: 'MaterialBindRecord_lineCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工位编码'),key: 'MaterialBindRecord_stationCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工单编号'),key: 'MaterialBindRecord_orderCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page排程编码'),key: 'MaterialBindRecord_scheduleCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.PageSN编码'),key: 'MaterialBindRecord_snNumber',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page组件物料编号'),key: 'MaterialBindRecord_assemblyMaterialCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page组件物料数量'),key: 'MaterialBindRecord_assemblyMaterialQty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page组装顺序'),key: 'MaterialBindRecord_assemblySort',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page组装时间'),key: 'MaterialBindRecord_assemblyTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page组件物料名称'),key: 'MaterialBindRecord_assemblyMaterialName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page组件物料版本'),key: 'MaterialBindRecord_assemblyMaterialVersion',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page组件物料sn'),key: 'MaterialBindRecord_assemblyMaterialSn',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page组件物料批次'),key: 'MaterialBindRecord_materialBatchNo',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page上传标志位'),key: 'MaterialBindRecord_uploadflag',type: 'switch',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'MaterialBindRecord_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'MaterialBindRecord_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'MaterialBindRecord_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'MaterialBindRecord_UpdateBy',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataMaterialBindRecord = () => {
    tableRefMaterialBindRecord.value.doSearch(materialbindrecordApi().search, searchDataMaterialBindRecord.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataMaterialBindRecord)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataMaterialBindRecord)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataMaterialBindRecord)
};

// 删除
const onDelete = (row: any) => {
    materialbindrecordApi().delete([row.ID]).then(() => { getTableDataMaterialBindRecord()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefMaterialBindRecord.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      materialbindrecordApi().delete(selectedids).then(() => { getTableDataMaterialBindRecord()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefMaterialBindRecord.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataMaterialBindRecord)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataMaterialBindRecord)
};

const onExport = () => {
	
    const selected = tableRefMaterialBindRecord.value.getSelectedRows();
	//console.log('ww',tableDataMaterialBindRecord.value.config.total);
    if (selected.length > 0) {
		materialbindrecordApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		materialbindrecordApi().export(searchDataMaterialBindRecord.value);
	}
    
};

import{useRoute} from "vue-router";
const route = useRoute();

// 页面加载时
onMounted(() => {
    if(typeof(route.query.snNumber)=="undefined"){

        }else{
            searchDataMaterialBindRecord.value.SnNumber = route.query.snNumber
        }
        getTableDataMaterialBindRecord();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

